﻿using System;
using System.Collections.Generic;
using System.IO;
using Xenta.Entities;

namespace Xenta.Plugins
{
    /// <summary>
    /// Exposes the file storage interface.
    /// </summary>
    public interface IFileStorage : IPlugin
    {
        #region Properties

        /// <summary>
        /// Gets the storage specific state
        /// information.
        /// </summary>
        IDictionary<String, String> State
        {
            get;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Creates the file.
        /// </summary>
        /// <param name="file">The file entity.</param>
        void Create(FileEntity file);

        /// <summary>
        /// Determines, if the file exists in the storage.
        /// </summary>
        /// <param name="file">The file entity.</param>
        /// <returns>true if file exists; otherwise false.</returns>
        bool Exists(FileEntity file);

        /// <summary>
        /// Writes the file.
        /// </summary>
        /// <param name="file">The file entity.</param>
        /// <param name="inStream">The input data stream.</param>
        /// <returns>The number of bytes written to file.</returns>
        long Write(FileEntity file, Stream inStream);

        /// <summary>
        /// Reads the file.
        /// </summary>
        /// <param name="file">The file entity.</param>
        /// <param name="outStream">The output data stream.</param>
        /// <returns>The number of bytes read from file.</returns>
        long Read(FileEntity file, Stream outStream);

        /// <summary>
        /// Deletes the file.
        /// </summary>
        /// <param name="file">The file entity.</param>
        void Delete(FileEntity file);

        #endregion
    }
}
